package com.xiaoyu.lanling.feature.friend.activity

import android.os.Bundle
import com.xiaoyu.base.utils.extensions.setOnClickDebounceListener
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.activity.base.AppCompatToolbarActivity
import com.xiaoyu.lanling.activity.base.BaseAppCompatActivity
import com.xiaoyu.lanling.activity.base.BaseFragment
import com.xiaoyu.lanling.feature.friend.fragment.FansListFragment
import com.xiaoyu.lanling.feature.friend.fragment.FriendListFragment
import com.xiaoyu.lanling.feature.friend.fragment.SubscribeListFragment
import com.xiaoyu.lanling.feature.login.fragment.LoginCellphoneFragment
import com.xiaoyu.lanling.feature.login.fragment.LoginCodeFragment
import com.xiaoyu.lanling.view.FragmentAdapter
import com.xiaoyu.lanling.view.OnShowFragment
import com.xiaoyu.lanling.widget.tablayout.ScaleTabLayoutUtils
import kotlinx.android.synthetic.main.activity_friend.*

class FriendListActivity : AppCompatToolbarActivity() {

    private val fragmentList: MutableList<OnShowFragment> = mutableListOf()

    override fun onCreateSafelyAfterAppFinishInit(savedInstanceState: Bundle?) {
        super.onCreateSafelyAfterAppFinishInit(savedInstanceState)
        setLightStatusBar()
        setContentView(R.layout.activity_friend)

        initBind()
        initViewPager()
    }

    private fun initBind() {
        back.setOnClickDebounceListener { finish() }
    }

    private fun initViewPager() {
        val titles: MutableList<CharSequence> = mutableListOf()
        titles.add(getString(R.string.friend_list_tab_friend))
        titles.add(getString(R.string.friend_list_tab_subsribe))
        titles.add(getString(R.string.friend_list_tab_fans))

        fragmentList.add(FriendListFragment())
        fragmentList.add(SubscribeListFragment())
        fragmentList.add(FansListFragment())

        ScaleTabLayoutUtils.createNormalScaleTabLayout(toolbar_tab_layout, view_pager, titles, false)

        val fragmentAdapter = FragmentAdapter(supportFragmentManager, fragmentList, titles)
        view_pager.offscreenPageLimit = fragmentList.size
        view_pager.adapter = fragmentAdapter
    }
}